<template>
  <div>
    <h2>岗位管理</h2><hr>
    <el-table
        ref="multipleTable"
        :data="tableData"
        tooltip-effect="dark"
        style="width: 100%"
        @selection-change="handleSelectionChange">
      <el-table-column
          type="selection"
          width="55">
      </el-table-column>
      <el-table-column
          prop="name"
          label="岗位名称"
          width="120">
      </el-table-column>
      <el-table-column
          prop="orders"
          label="显示排序"
          show-overflow-tooltip>
      </el-table-column>
    </el-table>
    <div style="margin-top: 20px">
      <el-button @click="toggleSelection([tableData[1], tableData[2]])">切换第二、第三行的选中状态</el-button>
      <el-button @click="toggleSelection()">取消选择</el-button>
    </div>
  </div>
</template>

<script>
export default {
  name: "PostView",
  data(){
    return{
      tableData:[]
    }
  },methods:{
    postList(){
      this.axios.post("http://172.20.10.5:8003/api/tb-post/postList").then(res=>{
        this.tableData=res.data
      })
    },
    toggleSelection(rows) {
      if (rows) {
        rows.forEach(row => {
          this.$refs.multipleTable.toggleRowSelection(row);
        });
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    }
  },created() {
    this.postList();
  }
}
</script>

<style scoped>

</style>